﻿using System;
using System.Collections.Generic;
using System.Text;

namespace LanhuFx.Identity
{
    public class ResponseException : Exception
    {
        public string State { get; set; }

        public ResponseStateCdode Code { get; set; }

        public Exception exData { get; set; }

        public ResponseException(ResponseStateCdode code, string message) : base(message)
        {
            this.Code = code;
            this.State = CodeToState(code);
        }

        public ResponseException(Exception ex, ResponseStateCdode code, string message) : base(message)
        {
            this.Code = code;
            this.State = CodeToState(code);
            this.exData = ex;
        }

        private string CodeToState(ResponseStateCdode code)
        {
            switch (code)
            {
                case ResponseStateCdode.error:
                    return "Error";
                case ResponseStateCdode.notdefind:
                    return "NotDefind";
                case ResponseStateCdode.identityerror:
                    return "IdentityError";
            }
            return "";
        }
    }

    public enum ResponseStateCdode
    {
        success = 200,
        error = 500,
        notdefind = 404,
        identityerror = 401
    }
}
